<template>
	<view class="indexs">
		<view class="header header_wi" :style="'padding-top: ' + navH + 'px;'">
			<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
				<view class="index_h_cont3">
					<view class="index_wenben_img" @tap="jumpzuo"><image :src="imgUrl + '/dzx_img33.png'" mode="widthFix"></image></view>
					<view class="index_wenben">{{ $t('page_baoguoyg_guojia.choose_country') }}</view>
				</view>
			</view>
			<view class="coloe_title">s</view>
		</view>
		<view class="index_center" :style="'padding-top:' + (navH + 50) + 'px;'">
			<view class="baoguoyg_guojia">
				<view class="baoguoyg_guojia_inputs">
					<view class="baoguoyg_guojia_input">
						<image :src="imgUrl + '/dzx_img38.png'"></image>
						<input type="text" :placeholder="$t('page_baoguoyg_guojia.search')" @confirm="huiche" @blur="huiche" @input="huiche" />
					</view>
				</view>

				<view class="baoguoyg_guojia_list">
					<view class="baoguoyg_guojia_cont" v-for="(item, index) in array" :key="index">
						<view class="baoguoyg_guojia_cont_t1">{{ index }}（{{ item.length }}个）</view>
						<view class="baoguoyg_guojia_cont_list">
							<view class="baoguoyg_guojia_cont_cont" @tap="fanhuiguojia" :data-id="items.id" :data-name="items.title" v-for="(items, index1) in item" :key="index1">
								{{ items.title }}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
// pages/shouye/shouye_zkc/shouye_zkc.js
const app = getApp();

let request = require('../../../utils/require');

export default {
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData.top,
			imgUrl: app.globalData.imgUrl,
			baoguo_on: 0,
			isshow: false,
			array: [],
			guojiaid: '',
			guojianame: ''
		};
	},
	/**
	 * 生命周期函数--监听页面加载
	 */ onLoad() {
		var that = this;
		that.guojialist('');
	},
	onShow() {
		var that = this;
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {},
	methods: {
		huiche(e) {
			this.array= []
			this.guojialist(e.detail.value);
		},

		guojialist(e) {
			var that = this;
			var data = {
				keyword: e
			};
			request.get(`index.php?s=/api/package/country&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					this.array= res.data.data
					console.log(res.data, 're?????');
				}
			});
		},

		jumpzuo() {
			uni.navigateBack();
		},

		fanhuiguojia(e) {
			var pages = getCurrentPages();
			var prevPage = pages[pages.length - 2];
			console.log(prevPage, '3333');
			prevPage.guojiaid= e.currentTarget.dataset.id
			prevPage.guojianame= e.currentTarget.dataset.name
			console.log(prevPage, 'prevPage???');
			uni.navigateBack({
				delta: 1
			});
		}
	}
};
</script>
<style>
@import './baoguoyg_guojia.css';
</style>
